package com.zhkj.txg.module.product.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.zhkj.lib.utils.ScreenUtil
import com.zhkj.lib.utils.SpanUtil
import com.zhkj.txg.R
import com.zhkj.txg.utils.ImageUtils
import java.io.Serializable

class ProductShareAdapter : BaseQuickAdapter<ShareProductUIEntity, BaseViewHolder>(R.layout.item_product_share) {
    override fun convert(helper: BaseViewHolder, item: ShareProductUIEntity) {
        helper.setText(R.id.tvProductTitle, item.productName)
            .setText(R.id.tvProductPrice, SpanUtil.setMoneySymbol(item.productPrice))
            .setText(R.id.tvProduct, "来自${item.introduce}的推荐")
        ImageUtils.loadRoundCornerImage(
            context,
            helper.getView(R.id.ivProductPic),
            item.productImg,
            ScreenUtil.dip(context, 10)
        )
        ImageUtils.loadRoundCornerImage(
            context,
            helper.getView(R.id.ivProductCode),
            item.qrCode,
            ScreenUtil.dip(context, 10)
        )
    }
}

data class ShareProductUIEntity(
    val productName: String,
    val productPrice: String,
    val introduce: String,
    val qrCode: String,
    val productImg: String
) : Serializable